Counter Operations for IEC

See also: IEC 61131 Language Editor Programming

See also: Project Toolbox for IEC

 

Topic Menu

 

Down Counter

CTD

Function - Down counter.

 

Inputs

CD : BOOLClosed Boolean- [Data Type BOOL] - A single bit, binary value, or register/variable. Boolean points have only two possible values, 'TRUE' or 'FALSE'. - Enable counting. Counter is decreased on each call when CD is TRUE

LOAD : BOOL - Re-load command. Counter is set to PV when called with LOAD to TRUE

PV : INTClosed Integer - [Data Type INT] - A 16-bit signed value. Integers are used where the value of the data is expected to be in the range of -32,768 to +32,767. - Programmed maximum value

 

Outputs

Q : BOOL TRUE - when counter is empty, i.e. when CV = 0

CV : INT - Current value of the counter

Remarks - The counter is empty (CV = 0) when the application starts. Counter is set to PV when called with LOAD to TRUE. The counter does not include a pulse detection for CD input. Use R_TRIG or F_TRIG function block for counting pulses of CD input signal. In LD language, CD is the input rung. The output rung is the Q output.

 

ST Language

(* MyCounter is a declared instance of CTD function block *)

MyCounter (CD, LOAD, PV);

Q := MyCounter.Q;

CV := MyCounter.CV;

 

FBD Language

 

LD Language

 

IL Language

(* MyCounter is a declared instance of CTD function block *)

Return to the Top: Counter Operations for IEC

 

Up Counter

CTU

Function - Up counter

 

Inputs

CU : BOOL - Enable counting. Counter is increased on each call when CU is TRUE

RESET : BOOL - Reset command. Counter is reset to 0 when called with RESET to TRUE

PV : INT - Programmed maximum value

 

Outputs

Q : BOOL TRUE - when counter is full, i.e. when CV = PV

CV : INT - Current value of the counter

Remarks - The counter is empty (CV = 0) when the application starts. The counter does not include a pulse detection for CU input. Use R_TRIG or F_TRIG function block for counting pulses of CU input signal. In LD language, CU is the input rung. The output rung is the Q output.

 

ST Language

(* MyCounter is a declared instance of CTU function block *)

MyCounter (CU, RESET, PV);

Q := MyCounter.Q;

CV := MyCounter.CV;

 

FBD Language

 

LD Language

 

IL Language

(* MyCounter is a declared instance of CTU function block *)

Return to the Top: Counter Operations for IEC